package com.ims.core.saleconfig.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ims.common.annotation.Log;
import com.ims.common.core.controller.BaseController;
import com.ims.common.core.domain.AjaxResult;
import com.ims.common.enums.BusinessType;
import com.ims.core.saleconfig.domain.TSalTaxCategory;
import com.ims.core.saleconfig.service.ITSalTaxCategoryService;
import com.ims.common.utils.poi.ExcelUtil;
import com.ims.common.core.page.TableDataInfo;

/**
 * 税收分类Controller
 *
 * @author IMS
 * @date 2024-05-20
 */
@RestController
@RequestMapping("/saleconfig/taxcategory")
public class TSalTaxCategoryController extends BaseController
{
    @Autowired
    private ITSalTaxCategoryService tSalTaxCategoryService;

    /**
     * 查询税收分类列表
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:taxcategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(TSalTaxCategory tSalTaxCategory)
    {
        startPage();
        List<TSalTaxCategory> list = tSalTaxCategoryService.selectTSalTaxCategoryList(tSalTaxCategory);
        return getDataTable(list);
    }

    /**
     * 导出税收分类列表
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:taxcategory:export')")
    @Log(title = "税收分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TSalTaxCategory tSalTaxCategory)
    {
        List<TSalTaxCategory> list = tSalTaxCategoryService.selectTSalTaxCategoryList(tSalTaxCategory);
        ExcelUtil<TSalTaxCategory> util = new ExcelUtil<TSalTaxCategory>(TSalTaxCategory.class);
        util.exportExcel(response, list, "税收分类数据");
    }

    /**
     * 获取税收分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:taxcategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tSalTaxCategoryService.selectTSalTaxCategoryById(id));
    }

    /**
     * 新增税收分类
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:taxcategory:add')")
    @Log(title = "税收分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSalTaxCategory tSalTaxCategory)
    {
        return toAjax(tSalTaxCategoryService.insertTSalTaxCategory(tSalTaxCategory));
    }

    /**
     * 修改税收分类
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:taxcategory:edit')")
    @Log(title = "税收分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSalTaxCategory tSalTaxCategory)
    {
        return toAjax(tSalTaxCategoryService.updateTSalTaxCategory(tSalTaxCategory));
    }

    /**
     * 删除税收分类
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:taxcategory:remove')")
    @Log(title = "税收分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tSalTaxCategoryService.deleteTSalTaxCategoryByIds(ids));
    }
}
